package cn.goktech.oss.controller;

import cn.goktech.oss.service.IAvatarService;
import cn.goktech.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss/avatar")
@Api(description = "讲师头像操作")
@CrossOrigin
public class AvatarController {

    @Autowired
    private IAvatarService avatarService;

    @PostMapping("/upload/file")
    @ApiOperation("讲师头像上传")
    @CrossOrigin
    public ResultUtil avatarUpload(
            @ApiParam(name="file", value = "讲师头像文件",required = true)
            @RequestParam("file") MultipartFile file){
        return ResultUtil.ok().data("url",avatarService.avatarUpload(file));
    }
}
